﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using Core.NTier.Entities;
using K2CoreLib.Dao.Hcs;
using Core.ExceptionHandling;
using vHCS.HR.Entities;
using System.Data;

namespace K2CoreLib.DataProvider
{
    public class EmpFilter
    {
        /// <summary>
        /// Get Combo employees request for role admin or HRBP 
        /// </summary>
        public Collection<DropDownListItem> GetComboUserForHrbpOrAdmin(string prefix, bool addNullItem, bool getTop)
        {
            Collection<DropDownListItem> result = new Collection<DropDownListItem>();
            try
            {
                EmployeeFilterDao empFilterDao = new EmployeeFilterDao();
                IEnumerable<DropDownListItem> dtoList = empFilterDao.GetEmployeesOfHrbpOrAdmin(prefix, getTop);
                foreach (DropDownListItem dto in dtoList)
                    result.Add(dto);

                if (addNullItem)
                {
                    DropDownListItem emptyItem = new DropDownListItem();
                    result.Insert(0, emptyItem);
                }

            }
            catch (Exception ex)
            {
                BusinessLogicExceptionHandler.HandleExcetion(ex);
            }
            return result;
        }

        /// <summary>
        /// Get Employees for pop up search of Role Admin or HRBP
        /// </summary>
        public DataTable GetEmployeeSearchOfHrbpOrAdmin(HR_UserSeachDTO p_dtoUserSearch, long p_CalledFunctionId, bool usertrue, bool IsView)
        {
            EmployeeFilterDao empFilterDao = new EmployeeFilterDao();
            DataTable dt = new DataTable();
            if (IsView)
                dt = empFilterDao.SearchEmpployeesOfHrbpOrAdmin(p_dtoUserSearch, p_CalledFunctionId, usertrue);
            return dt;
        }
    }
}
